package Lee_code;

public class Lee_19 {
    public class ListNode {
      int val;
      ListNode next;
      ListNode() {}
      ListNode(int val) { this.val = val; }
      ListNode(int val, ListNode next) { this.val = val; this.next = next; }
  }
    public ListNode removeNthFromEnd(ListNode head, int n)
    {
        ListNode temp = head;
        ListNode fake_head = new ListNode(0);
        fake_head.next = head;
        for(int i=0; i<n; i++)
            temp = temp.next;

        while(temp!=null)
        {
            temp = temp.next;
            fake_head = fake_head.next;
        }
        fake_head.next = fake_head.next.next;
        return head;
    }
}
